package com.hzdp.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

public class BaseAction implements ServletRequestAware, ServletResponseAware {

	protected Logger logger = Logger.getLogger(getClass());

	protected int getUserId() {
		int userId = 0;
		try {
			userId = (Integer) request.getAttribute("ContextUser");
		} catch (Exception e) {
		}
		return userId;
	}

	public static String SUCCESS = "success";
	public static String FAIL = "fail";

	public String execute() {
		return SUCCESS;
	}

	protected HttpServletRequest request;
	protected HttpServletResponse response;

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	private String UUID;

	protected String getUUID() {
		if (UUID == null) {
			Object value = request.getAttribute("UUID");
			if (value != null) {
				UUID = value.toString();
			}
		}
		return UUID;
	}
}
